﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.MonthCalendar;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textArea_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnCalculate_Click(object sender, EventArgs e)
        {
            // 1. 从 textBox1 取半径（字符串转 double）
            if (double.TryParse(textBox1.Text, out double radius))
            {
                // 2. 计算面积和周长
                double area = Math.PI * radius * radius;
                double circumference = 2 * Math.PI * radius;

                // 3. 显示到只读 TextBox
                txtArea.Text = area.ToString("F5");       // 面积保留 5 位小数
                txtCircumference.Text = circumference.ToString("F6"); // 周长保留 6 位小数
            }
            else
            {
                MessageBox.Show("请输入有效的半径数值！");
            }
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
            txtArea.Clear();
            txtCircumference.Clear();
        }
    }
}

